<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>
    SocketError when using PRAW : Forums : PythonAnywhere
</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta name="description" content="Forums : PythonAnywhere">
        <meta name="author" content="PythonAnywhere LLP">
        <meta name="google-site-verification" content="O4UxDrfcHjC44jybs2vajc1GgRkTKCTRgVzeV6I9V14" />

        <!-- Le styles -->
        <link href="/static/bootstrap/css/bootstrap.css" rel="stylesheet">
        <link href="/static/bootstrap/css/bootstrap-responsive.css" rel="stylesheet">
        <link href="/static/anywhere/styles/bootstrap_base.css" rel="stylesheet">
        
    
    <link rel="stylesheet" href="/static/anywhere/styles/forums.css" type="text/css" media="screen" charset="utf-8" />

    <link rel="stylesheet" href="/static/pygments/style.css" type="text/css" media="screen" charset="utf-8" />

        <link rel="stylesheet" href="/static/jquery/jquery-ui-1.8.11.custom.css" type="text/css" media="screen" charset="utf-8" />
        
    
    <link rel="alternate" type="application/rss+xml" title="RSS" href="/forums/topic/628/rss" />

        <style type="text/css">
            body {
                height: auto;
            }
        </style>
        <!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
        <!--[if lt IE 9]>
        <script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script>
        <![endif]-->

        <!-- Le fav and touch icons -->
        <link rel="apple-touch-icon" href="images/apple-touch-icon.png">
        <link rel="apple-touch-icon" sizes="72x72" href="images/apple-touch-icon-72x72.png">
        <link rel="apple-touch-icon" sizes="114x114" href="images/apple-touch-icon-114x114.png">
    </head>

     <body>
        <div class="navbar navbar-fixed-top">
            <div class="navbar-inner">
                <div id="id_internal_nav_bar_container" class="container">
                    <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    </a>
                    <a class="brand" href="/"><img id="id_logo" src="/static/anywhere/images/logo-234x35.png" height="35" title="PythonAnywhere logo" alt="PythonAnywhere logo" /></a>
                    <div class="nav-collapse">
                        <ul id="id_header_links" class="nav">
                            <li><a id="id_feedback_link" class='feedback_link' href="">Send feedback</a></li>
                            <li><a id="id_forums_link" href="/forums/">Forums</a></li>
                            <li><a href="/wiki/" id="id_help_link">Help</a></li>
                            <li><a href="http://blog.pythonanywhere.com/" id="id_blog_link">Blog</a></li>
                            
                            
                                <li><a style="font-weight: bold;" href="/pricing/" id="id_pricing_link">Pricing & signup</a></li>
                                <li><a href="/login/?next=/forums/topic/628/" id="id_login_link">Log in</a></li>
                            
                        </ul>
                    </div>
                </div>
            </div>
        </div>

        <div class="top-container" id="id_dummy"></div>

        

        
    
    <div class="container">
        <div class="row">
            <div class="span8 offset3">
                <h1>PythonAnywhere Forums</h1>
            </div>
        </div>



    <div class="row">
        <div class="span8 offset3">
            <p>
                <a href="/forums/start_topic/" id="id_start_new_topic">Start a new topic</a> |
                <a href="/forums/">Back to all topics</a> |
                <a href="/forums/topic/628/rss">This topic's RSS</a>
            </p>
        </div>
    </div>
    <div class="row">
        <div class="span8 offset3 topic">
            <h2>SocketError when using PRAW</h2>
        </div>
    </div>

    
        <div class="row">
            <div id="id_post_4605" class="span8 offset3 post">
                <div class="row">
                    <div id="id_post_4605_content_text" class="span8">
                        
                    </div>
                </div>
                <div class="row">
                    <div class="span7 post_metadata">
                        <span id="id_post_4605_creator_details">
                            
                                
                            
                            bobbyllama
                            |
                            4
                            posts
                            |
                            
                        </span>
                        <span id="id_post_4605_created_date">
                            May 12, 2013, 3:03 a.m.
                        </span>
                        |
                        <a href="https://www.pythonanywhere.com/forums/topic/628/#id_post_4605">permalink</a>
                    </div>
                    <div class="span1">
                        
                    </div>
                </div>
            </div>
        </div>
    
        <div class="row">
            <div id="id_post_4608" class="span8 offset3 post">
                <div class="row">
                    <div id="id_post_4608_content_text" class="span8">
                        <p>I'm attempting to use a python script to post a submission to reddit using PRAW. The script works locally, but throws the following error on PA. Any ideas? Traceback looks like:</p>
<p>Traceback (most recent call last):
  File "/home/bobbyllama/3DS_Noob_Thread_Bot.py", line 34, in &lt;module&gt;                                                                                      <br />
    main()                                                                                                                                                  <br />
  File "/home/bobbyllama/3DS_Noob_Thread_Bot.py", line 31, in main                                                                                          <br />
    PostThread()                                                                                                                                            <br />
  File "/home/bobbyllama/3DS_Noob_Thread_Bot.py", line 26, in PostThread                                                                                    <br />
    Interface.login(BotName, BotPassword)                                                                                                                   <br />
  File "/home/bobbyllama/.local/lib/python2.7/site-packages/praw/<strong>init</strong>.py", line 1099, in login                                                          <br />
    self.request_json(self.config['login'], data=data)                                                                                                      <br />
  File "/home/bobbyllama/.local/lib/python2.7/site-packages/praw/decorators.py", line 95, in wrapped                                                        <br />
    return_value = function(reddit_session, <em>args, <strong>kwargs)                                                                                                <br />
  File "/home/bobbyllama/.local/lib/python2.7/site-packages/praw/<strong>init</strong>.py", line 468, in request_json                                                    <br />
    response = self._request(url, params, data)                                                                                                             <br />
  File "/home/bobbyllama/.local/lib/python2.7/site-packages/praw/<strong>init</strong>.py", line 341, in _request                                                        <br />
    response = handle_redirect()                                                                                                                            <br />
  File "/home/bobbyllama/.local/lib/python2.7/site-packages/praw/<strong>init</strong>.py", line 314, in handle_redirect                                                 <br />
    timeout=timeout, </strong>kwargs)                                                                                                                              <br />
  File "/home/bobbyllama/.local/lib/python2.7/site-packages/praw/handlers.py", line 135, in wrapped                                                         <br />
    result = function(cls, <strong>kwargs)                                                                                                                        <br />
  File "/home/bobbyllama/.local/lib/python2.7/site-packages/praw/handlers.py", line 54, in wrapped                                                          <br />
    return function(cls, </strong>kwargs)                                                                                                                          <br />
  File "/home/bobbyllama/.local/lib/python2.7/site-packages/praw/handlers.py", line 90, in request                                                          <br />
    allow_redirects=False)                                                                                                                                  <br />
  File "/usr/local/lib/python2.7/site-packages/requests/sessions.py", line 460, in send                                                                     <br />
    r = adapter.send(request, </em>*kwargs)                                                                                                                     <br />
  File "/usr/local/lib/python2.7/site-packages/requests/adapters.py", line 246, in send                                                                     <br />
    raise ConnectionError(e)                                                                                                                                <br />
requests.exceptions.ConnectionError: HTTPConnectionPool(host='www.reddit.com', port=80): Max retries exceeded with url: /api/login/.json (Caused by &lt;class 'so
cket.error'&gt;: [Errno 111] Connection refused)</p>
                    </div>
                </div>
                <div class="row">
                    <div class="span7 post_metadata">
                        <span id="id_post_4608_creator_details">
                            
                                
                            
                            bobbyllama
                            |
                            4
                            posts
                            |
                            
                        </span>
                        <span id="id_post_4608_created_date">
                            May 12, 2013, 3:40 p.m.
                        </span>
                        |
                        <a href="https://www.pythonanywhere.com/forums/topic/628/#id_post_4608">permalink</a>
                    </div>
                    <div class="span1">
                        
                    </div>
                </div>
            </div>
        </div>
    
        <div class="row">
            <div id="id_post_4610" class="span8 offset3 post">
                <div class="row">
                    <div id="id_post_4610_content_text" class="span8">
                        <p>Since <code>reddit.com</code> is on <a href="https://www.pythonanywhere.com/whitelist/">the whitelist</a> then as far as I can tell that should work fine. I suggest trying again periodically in case the proxy server is having issues, similar to <a href="https://www.pythonanywhere.com/forums/topic/517/">this one</a>.</p>
                    </div>
                </div>
                <div class="row">
                    <div class="span7 post_metadata">
                        <span id="id_post_4610_creator_details">
                            
                                
                                    <img src="/static/anywhere/images/star.gif" alt="Beloved premium user" title="Beloved premium user"/>
                                
                            
                            Cartroo
                            |
                            638
                            posts
                            |
                            
                        </span>
                        <span id="id_post_4610_created_date">
                            May 12, 2013, 9:07 p.m.
                        </span>
                        |
                        <a href="https://www.pythonanywhere.com/forums/topic/628/#id_post_4610">permalink</a>
                    </div>
                    <div class="span1">
                        
                    </div>
                </div>
            </div>
        </div>
    
        <div class="row">
            <div id="id_post_4611" class="span8 offset3 post">
                <div class="row">
                    <div id="id_post_4611_content_text" class="span8">
                        <p>The proxy server looks fine, and I can see requests for reddit.com going through OK.  Perhaps they're rate-limiting us from time to time?</p>
                    </div>
                </div>
                <div class="row">
                    <div class="span7 post_metadata">
                        <span id="id_post_4611_creator_details">
                            
                                <img src="/static/anywhere/images/staff.png" alt="Staff" title="Staff"/>
                            
                            giles
                            |
                            866
                            posts
                            |
                            
                                PythonAnywhere staff
                                |
                            
                        </span>
                        <span id="id_post_4611_created_date">
                            May 12, 2013, 9:43 p.m.
                        </span>
                        |
                        <a href="https://www.pythonanywhere.com/forums/topic/628/#id_post_4611">permalink</a>
                    </div>
                    <div class="span1">
                        
                    </div>
                </div>
            </div>
        </div>
    
        <div class="row">
            <div id="id_post_4617" class="span8 offset3 post">
                <div class="row">
                    <div id="id_post_4617_content_text" class="span8">
                        <p>I'm assuming that there's an ICMP "destination unreachable" coming back to result in the "connection refused" message in the backtrace above. It would be quite rude for Reddit to send ICMP errors in response to being rate-limited - even a relatively dumb load-balancer should be able to send back a static <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.5.4">503 response</a>, preferably with a <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.37">Retry-After</a> header.</p>
<p>I'm not saying they're <em>not</em> doing that - just that it would be quite rude on their part! (^_^)</p>
<p>As an aside, I've failed to trigger any rate-limiting by some not-too-aggressive methods (<strong><em>NOT</em></strong> running on PA, I hasten to add!), so if they are doing that then either it's a manually-imposed thing, or the bar is quite high for triggering it.</p>
<p>@bobbyllama: Have you seen any of your requests work, or have you got an error every single time?</p>
                    </div>
                </div>
                <div class="row">
                    <div class="span7 post_metadata">
                        <span id="id_post_4617_creator_details">
                            
                                
                                    <img src="/static/anywhere/images/star.gif" alt="Beloved premium user" title="Beloved premium user"/>
                                
                            
                            Cartroo
                            |
                            638
                            posts
                            |
                            
                        </span>
                        <span id="id_post_4617_created_date">
                            May 13, 2013, 10:12 a.m.
                        </span>
                        |
                        <a href="https://www.pythonanywhere.com/forums/topic/628/#id_post_4617">permalink</a>
                    </div>
                    <div class="span1">
                        
                    </div>
                </div>
            </div>
        </div>
    
        <div class="row">
            <div id="id_post_4620" class="span8 offset3 post">
                <div class="row">
                    <div id="id_post_4620_content_text" class="span8">
                        <p>It looks like everything in your account is as it should be for reddit to be contactable. Could you try a wget in a new bash console?</p>
                    </div>
                </div>
                <div class="row">
                    <div class="span7 post_metadata">
                        <span id="id_post_4620_creator_details">
                            
                                <img src="/static/anywhere/images/staff.png" alt="Staff" title="Staff"/>
                            
                            glenn
                            |
                            418
                            posts
                            |
                            
                                PythonAnywhere staff
                                |
                            
                        </span>
                        <span id="id_post_4620_created_date">
                            May 13, 2013, 11:41 a.m.
                        </span>
                        |
                        <a href="https://www.pythonanywhere.com/forums/topic/628/#id_post_4620">permalink</a>
                    </div>
                    <div class="span1">
                        
                    </div>
                </div>
            </div>
        </div>
    
        <div class="row">
            <div id="id_post_4781" class="span8 offset3 post">
                <div class="row">
                    <div id="id_post_4781_content_text" class="span8">
                        <p>Thanks for the replies, all. Sorry I forgot about this thread for a few days. Getting ready to move into a new apartment next week and it completely slipped my mind.</p>
<p>@Cartroo: This script has not once run on PA. It works like a charm locally, however.</p>
<p>@glenn: Sure can! Results as follows:</p>
<div class="codehilite"><pre><span class="mi">23</span><span class="o">:</span><span class="mi">21</span> <span class="o">~</span> <span class="n">$</span> <span class="n">wget</span> <span class="n">http</span><span class="o">://</span><span class="n">www</span><span class="o">.</span><span class="na">reddit</span><span class="o">.</span><span class="na">com</span>                                                                                                                          
<span class="o">--</span><span class="mi">2013</span><span class="o">-</span><span class="mi">05</span><span class="o">-</span><span class="mi">23</span> <span class="mi">23</span><span class="o">:</span><span class="mi">21</span><span class="o">:</span><span class="mi">22</span><span class="o">--</span>  <span class="n">http</span><span class="o">://</span><span class="n">www</span><span class="o">.</span><span class="na">reddit</span><span class="o">.</span><span class="na">com</span><span class="o">/</span>
<span class="n">Resolving</span> <span class="n">proxy</span><span class="o">.</span><span class="na">server</span><span class="o">...</span> <span class="mf">10.93</span><span class="o">.</span><span class="mf">19.94</span>
<span class="n">Connecting</span> <span class="n">to</span> <span class="n">proxy</span><span class="o">.</span><span class="na">server</span><span class="o">|</span><span class="mf">10.93</span><span class="o">.</span><span class="mf">19.94</span><span class="o">|:</span><span class="mi">3128</span><span class="o">...</span> <span class="n">connected</span><span class="o">.</span>
<span class="n">Proxy</span> <span class="n">request</span> <span class="n">sent</span><span class="o">,</span> <span class="n">awaiting</span> <span class="n">response</span><span class="o">...</span> <span class="mi">200</span> <span class="n">OK</span>
<span class="n">Length</span><span class="o">:</span> <span class="n">unspecified</span> <span class="o">[</span><span class="n">text</span><span class="o">/</span><span class="n">html</span><span class="o">]</span>
<span class="n">Saving</span> <span class="n">to</span><span class="o">:</span> <span class="err">`</span><span class="n">index</span><span class="o">.</span><span class="na">html</span><span class="s1">&#39;</span>

<span class="s1">    [ &lt;=&gt;                                                                                                                 ] 138,662     --.-K/s   in 0.005s</span>

<span class="s1">2013-05-23 23:21:23 (29.2 MB/s) - `index.html&#39;</span> <span class="n">saved</span> <span class="o">[</span><span class="mi">138662</span><span class="o">]</span>
</pre></div>
                    </div>
                </div>
                <div class="row">
                    <div class="span7 post_metadata">
                        <span id="id_post_4781_creator_details">
                            
                                
                            
                            bobbyllama
                            |
                            4
                            posts
                            |
                            
                        </span>
                        <span id="id_post_4781_created_date">
                            May 23, 2013, 11:22 p.m.
                        </span>
                        |
                        <a href="https://www.pythonanywhere.com/forums/topic/628/#id_post_4781">permalink</a>
                    </div>
                    <div class="span1">
                        
                    </div>
                </div>
            </div>
        </div>
    
        <div class="row">
            <div id="id_post_4859" class="span8 offset3 post">
                <div class="row">
                    <div id="id_post_4859_content_text" class="span8">
                        <p>@bobbyllama did this get resolved? I'm having the same issue.</p>
                    </div>
                </div>
                <div class="row">
                    <div class="span7 post_metadata">
                        <span id="id_post_4859_creator_details">
                            
                                
                            
                            mikenon
                            |
                            3
                            posts
                            |
                            
                        </span>
                        <span id="id_post_4859_created_date">
                            June 2, 2013, 4:24 p.m.
                        </span>
                        |
                        <a href="https://www.pythonanywhere.com/forums/topic/628/#id_post_4859">permalink</a>
                    </div>
                    <div class="span1">
                        
                    </div>
                </div>
            </div>
        </div>
    
        <div class="row">
            <div id="id_post_4905" class="span8 offset3 post">
                <div class="row">
                    <div id="id_post_4905_content_text" class="span8">
                        <p>@mikenon Nope. The script continues to run locally, but fails to run on PA.</p>
                    </div>
                </div>
                <div class="row">
                    <div class="span7 post_metadata">
                        <span id="id_post_4905_creator_details">
                            
                                
                            
                            bobbyllama
                            |
                            4
                            posts
                            |
                            
                        </span>
                        <span id="id_post_4905_created_date">
                            June 7, 2013, 3:04 p.m.
                        </span>
                        |
                        <a href="https://www.pythonanywhere.com/forums/topic/628/#id_post_4905">permalink</a>
                    </div>
                    <div class="span1">
                        
                    </div>
                </div>
            </div>
        </div>
    
        <div class="row">
            <div id="id_post_4910" class="span8 offset3 post">
                <div class="row">
                    <div id="id_post_4910_content_text" class="span8">
                        <p>Somebody else asked about this a few days ago.  It looks like PRAW doesn't recognise the proxy setting.  You could try and hack a fix yourself, or report a bug against their project...</p>
<p><a href="https://www.pythonanywhere.com/forums/topic/665/">https://www.pythonanywhere.com/forums/topic/665/</a></p>
                    </div>
                </div>
                <div class="row">
                    <div class="span7 post_metadata">
                        <span id="id_post_4910_creator_details">
                            
                                <img src="/static/anywhere/images/staff.png" alt="Staff" title="Staff"/>
                            
                            harry
                            |
                            376
                            posts
                            |
                            
                                PythonAnywhere staff
                                |
                            
                        </span>
                        <span id="id_post_4910_created_date">
                            June 8, 2013, 8:13 a.m.
                        </span>
                        |
                        <a href="https://www.pythonanywhere.com/forums/topic/628/#id_post_4910">permalink</a>
                    </div>
                    <div class="span1">
                        
                    </div>
                </div>
            </div>
        </div>
    

    




        <div id="id_footer" class="container">

            <footer id="id_copyright_div">
                <p>
                    Copyright &copy; 2013 PythonAnywhere LLP
                    &mdash;
                    <a href="/terms/">Terms</a>
                    &mdash;
                    <a href="/privacy/">Privacy</a><br/>
                    "Python" is a registered trademark of the Python Software Foundation.
                </p>
            </footer>

        </div>

        
        

        <div id="id_feedback_dialog" title="Help us improve" style="display:none">
    <div id="id_feedback_dialog_blurb_big" class="dialog_blurb_big">
        It's always a pleasure to hear from you!
    </div>
    <div id="id_feedback_dialog_blurb_small">
        Ask us a question, or tell us what you love or hate about PythonAnywhere.<br/>
        We'll get back to you over email ASAP.
    </div>
    <textarea id="id_feedback_dialog_text" rows="6"></textarea>
    <input id="id_feedback_dialog_email_address" type="text" class="default_prompt"/>
    <div id="id_feedback_dialog_error" class="pa_hidden">
        Sorry, there was an error connecting to the server. <br/>Please try again in a few moments...
    </div>
    <div class="dialog_buttons">
        <img id="id_feedback_dialog_spinner" src="/static/anywhere/images/spinner-small.gif" />
        <button class="btn btn-primary" id="id_feedback_dialog_ok_button">OK</button>
        <button class="btn" id="id_feedback_dialog_cancel_button">Cancel</button>
    </div>
</div>


        <!-- Le javascript
        ================================================== -->
        <!-- Placed at the end of the document so the pages load faster -->
        <script type="text/javascript" src="/static/jquery/jquery-1.7.1.min.js"></script>
        <script type="text/javascript" src="/static/jquery/jquery-ui-1.8.11.custom.min.js"></script>
        <script src="/static/bootstrap/js/bootstrap-transition.js"></script>
        <script src="/static/bootstrap/js/bootstrap-alert.js"></script>
        <script src="/static/bootstrap/js/bootstrap-modal.js"></script>
        <script src="/static/bootstrap/js/bootstrap-dropdown.js"></script>
        <script src="/static/bootstrap/js/bootstrap-scrollspy.js"></script>
        <script src="/static/bootstrap/js/bootstrap-tab.js"></script>
        <script src="/static/bootstrap/js/bootstrap-tooltip.js"></script>
        <script src="/static/bootstrap/js/bootstrap-popover.js"></script>
        <script src="/static/bootstrap/js/bootstrap-button.js"></script>
        <script src="/static/bootstrap/js/bootstrap-collapse.js"></script>
        <script src="/static/bootstrap/js/bootstrap-carousel.js"></script>
        <script src="/static/bootstrap/js/bootstrap-typeahead.js"></script>

        <script type="text/javascript">
            var urls = {};
            var Anywhere = {};
            Anywhere.urls = {};
        </script>
        <script type="text/javascript" src="/static/anywhere/scripts/ajax_utils.js"></script>

        <script type="text/javascript" src="/static/anywhere/scripts/feedback_dialog.js"></script>
        
        <script type="text/javascript">
            $(function() {
                $.extend(
                    urls,
                    {
                        feedback: '/feedback/submit/'
                    }
                );
                
                    Anywhere.FeedbackDialog.Initialise(urls, false);
                
            });
        </script>

        <script type="text/javascript">

            var _gaq = _gaq || [];
            _gaq.push(['_setAccount', 'UA-18014859-6']);
            _gaq.push(['_trackPageview']);

            (function() {
                var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
                ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
                var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
            })();

        </script>

        



    </body>
</html>
